using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Flan.Controls;

public partial class _07_Customer_Search : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e) {
        UpdatePanelPopupExtender.RegisterCloseControl(divClose, UpdatePanel1);

        ScriptManager sm = ScriptManager.GetCurrent(this.Page);
        sm.RegisterAsyncPostBackControl(TextBox1);
        sm.RegisterAsyncPostBackControl(Button1);

        //Handle TextBox postback - occurs when user hits the 'enter' key inside textbox in some browsers.
        //Others raise the button click event.
        if (sm.IsInAsyncPostBack) {
            System.Threading.Thread.Sleep(500);
            if (sm.AsyncPostBackSourceElementID == TextBox1.UniqueID) {
                DisplaySearchResults();
            }
        }
    }

    protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e) {
        Label1.Text = "Found " + e.AffectedRows + " records.";
    }
    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) {
        if (e.Row.RowType == DataControlRowType.DataRow) {
            LinkButton LinkButton1 = (LinkButton)e.Row.FindControl("LinkButton1");
            UpdatePanelPopupExtender.RegisterCloseControl(LinkButton1, UpdatePanel1);
        }
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) {
        if (e.CommandName != "Select") {
            UpdatePanel1.Update();
        }
    }

    /// <summary>
    /// Handle button click postback
    /// </summary>
    protected void Button1_Click(object sender, EventArgs e) {
        DisplaySearchResults();
    }

    protected void DisplaySearchResults() {
        GridView1.PageIndex = 0;
        UpdatePanelPopupExtender1.ShowAt(TextBox1);
        UpdatePanel1.Update();
    }
}
